home *** CD-ROM | disk | FTP | other *** search
/ Micromanía: 150 Juegos 2010 / 150Juegos_16.iso / Shareware / Shape Smash / shape-smash.swf / scripts / mx / core / LayoutContainer.as < prev    next >
Encoding:
Text File  |  2010-05-14  |  3.7 KB  |  129 lines

  1. package mx.core
  2. {
  3.    import flash.events.Event;
  4.    import flash.system.ApplicationDomain;
  5.    import mx.containers.BoxDirection;
  6.    import mx.containers.utilityClasses.BoxLayout;
  7.    import mx.containers.utilityClasses.CanvasLayout;
  8.    import mx.containers.utilityClasses.Layout;
  9.    import mx.resources.ResourceBundle;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class LayoutContainer extends Container
  14.    {
  15.       private static var viewSourceMenuItem:String;
  16.       
  17.       mx_internal static const VERSION:String = "2.0.1.0";
  18.       
  19.       private static var packageResources:ResourceBundle = ResourceBundle.getResourceBundle("core",ApplicationDomain.currentDomain);
  20.       
  21.       mx_internal static var useProgressiveLayout:Boolean = false;
  22.       
  23.       loadResources();
  24.       
  25.       private var _layout:String = "vertical";
  26.       
  27.       private var processingCreationQueue:Boolean = false;
  28.       
  29.       private var creationQueue:Array;
  30.       
  31.       protected var boxLayoutClass:Class;
  32.       
  33.       private var preloadObj:Object;
  34.       
  35.       private var resizeHandlerAdded:Boolean = false;
  36.       
  37.       protected var layoutObject:Layout;
  38.       
  39.       protected var canvasLayoutClass:Class;
  40.       
  41.       public function LayoutContainer()
  42.       {
  43.          layoutObject = new BoxLayout();
  44.          canvasLayoutClass = CanvasLayout;
  45.          boxLayoutClass = BoxLayout;
  46.          resizeHandlerAdded = false;
  47.          creationQueue = [];
  48.          processingCreationQueue = false;
  49.          _layout = ContainerLayout.VERTICAL;
  50.          super();
  51.          layoutObject.target = this;
  52.       }
  53.       
  54.       private static function loadResources() : void
  55.       {
  56.          viewSourceMenuItem = packageResources.getString("viewSource");
  57.       }
  58.       
  59.       override mx_internal function get usePadding() : Boolean
  60.       {
  61.          return layout != ContainerLayout.ABSOLUTE;
  62.       }
  63.       
  64.       override protected function measure() : void
  65.       {
  66.          super.measure();
  67.          layoutObject.measure();
  68.       }
  69.       
  70.       override protected function layoutChrome(param1:Number, param2:Number) : void
  71.       {
  72.          super.layoutChrome(param1,param2);
  73.          if(!mx_internal::doingLayout)
  74.          {
  75.             createBorder();
  76.          }
  77.       }
  78.       
  79.       public function set layout(param1:String) : void
  80.       {
  81.          if(_layout != param1)
  82.          {
  83.             _layout = param1;
  84.             if(layoutObject)
  85.             {
  86.                layoutObject.target = null;
  87.             }
  88.             if(_layout == ContainerLayout.ABSOLUTE)
  89.             {
  90.                layoutObject = new canvasLayoutClass();
  91.             }
  92.             else
  93.             {
  94.                layoutObject = new boxLayoutClass();
  95.                if(_layout == ContainerLayout.VERTICAL)
  96.                {
  97.                   BoxLayout(layoutObject).direction = BoxDirection.VERTICAL;
  98.                }
  99.                else
  100.                {
  101.                   BoxLayout(layoutObject).direction = BoxDirection.HORIZONTAL;
  102.                }
  103.             }
  104.             if(layoutObject)
  105.             {
  106.                layoutObject.target = this;
  107.             }
  108.             invalidateSize();
  109.             invalidateDisplayList();
  110.             dispatchEvent(new Event("layoutChanged"));
  111.          }
  112.       }
  113.       
  114.       [Bindable("layoutChanged")]
  115.       public function get layout() : String
  116.       {
  117.          return _layout;
  118.       }
  119.       
  120.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  121.       {
  122.          super.updateDisplayList(param1,param2);
  123.          layoutObject.updateDisplayList(param1,param2);
  124.          createBorder();
  125.       }
  126.    }
  127. }
  128.  
  129.